﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework.AppContainer;
using UnitTestWinRTConverters.ObjectsTestBase;
using WinRTConverters.Format;
using Assert = Microsoft.VisualStudio.TestPlatform.UnitTestFramework.Assert;

namespace UnitTestWinRTConverters
{
    [TestClass]
    public class FormatConvertersUnitTest
    {
        [UITestMethod]
        public void DoubleToStringConverterTest()
        {
            var objectTest = new UITextBoxTest(new DoubleToStringConverter(), 189.56);

            //Convert
            Assert.AreEqual("189,56", objectTest.ConvertValue);

            //ConvertBack
            objectTest.TextValue = "189,23";
            Assert.AreEqual(189.23, objectTest.ConvertBackValue);
        }

        [UITestMethod]
        public void StringFormatConverterTest()
        {
            var objectTest = new UITextBlockTest(new StringFormatConverter(), DateTime.Today, "{0:dddd dd MMMM yyyy}");            

            //Convert
            Assert.AreEqual(string.Format("{0:dddd dd MMMM yyyy}", DateTime.Today), objectTest.ConvertValue);
        }

        [UITestMethod]
        public void StringFormatUCaseConverterTest()
        {
            var objectTest = new UITextBlockTest(new StringFormatUCaseConverter(), DateTime.Today, "{0:dddd}");

            //Convert
            Assert.AreEqual(string.Format("{0:dddd}", DateTime.Today).ToUpper(), objectTest.ConvertValue);
        }

        [UITestMethod]
        public void StringFormatLCaseConverterTest()
        {
            var objectTest = new UITextBlockTest(new StringFormatLCaseConverter(), DateTime.Today, "{0:dddd}");

            //Convert
            Assert.AreEqual(string.Format("{0:dddd}", DateTime.Today).ToLower(), objectTest.ConvertValue);
        }

        [UITestMethod]
        public void InToMonthStringCultureConverterTest()
        {
            var objectTest = new UITextBlockTest(new IntToMonthStringCultureConverter(), DateTime.Today.Month);

            //Convert
            Assert.AreEqual(string.Format("{0:MMMM}", DateTime.Today), objectTest.ConvertValue);

            //Avec une autre culture
            var objectTestDe = new UITextBlockTest(new IntToMonthStringCultureConverter(), DateTime.Today.Month, "de-DE");

            //Convert
            Assert.AreEqual(string.Format(new CultureInfo("de-DE"), "{0:MMMM}", DateTime.Today), objectTestDe.ConvertValue);
        }
    }
}
